#include "FileOrFold.h"

FileOrFold::FileOrFold(QDialog *parent) : QDialog(parent)
{
    init();
}

FileOrFold::FileOrFold(QString Name) : QDialog()
{
    this->setWindowTitle(Name);
    init();
}
void FileOrFold::init(){
    QGridLayout *MainLayout = new QGridLayout();
    this->setLayout(MainLayout);

    this->FileButton = new QPushButton(tr("File"));
    this->FoldButton = new QPushButton(tr("Fold"));

    this->FileButton->setWhatsThis(tr("to open a file."));
    this->FoldButton->setWhatsThis(tr("to choose fold."));
    MainLayout->addWidget(this->FileButton,0,0,1,1);
    MainLayout->addWidget(this->FoldButton,0,1,1,1);

    this->setMinimumWidth(400);
    this->setWindowIcon(QIcon(":/QSS/image/Window_Icon.png"));
    this->setWindowFlags(Qt::Dialog);
    this->setModal(true);
    this->setWhatsThis(tr("File or fold?"));

    connect(this->FileButton,SIGNAL(clicked(bool)),this,SLOT(on_FileButton_clicked()));
    connect(this->FoldButton,SIGNAL(clicked(bool)),this,SLOT(on_FoldButton_clicked()));
}

void FileOrFold::on_FileButton_clicked(){
    this->OpenType = "FILE";
    this->accept();
}
void FileOrFold::on_FoldButton_clicked(){
    this->OpenType = "FOLD";
    this->accept();
}

QString FileOrFold::getType(){
    return this->OpenType;
}
void FileOrFold::closeEvent(QCloseEvent *e){
    this->reject();
}
